home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1998 July / EnigmA AMIGA RUN 29 (1998)(G.R. Edizioni)(IT)[!][issue 1998-07 & 08].iso / earkit / news / thor / rexx / keepmsg.thor < prev    next >
Text File  |  1998-05-24  |  5KB  |  166 lines

  1. /*
  2. ** $VER: KeepMsg.thor 1.4 (4.9.97)
  3. ** by Eirik Nicolai Synnes <eirikns@ifi.uio.no>
  4. **
  5. ** Copies the current or selected message to a special "Keep" conference and
  6. ** sets the KEEP flag on them.
  7. **
  8. ** Specify the conference name in the toconf string below. If the conference
  9. ** doesn't exist it will be created.
  10. **
  11. ** If you don't want the copy in the destination conference to be marked as
  12. ** unread make sure nomarkmsg is set to 1 below. Otherwise set it to 0.
  13. **
  14. ** Fixed in 1.3c:
  15. ** o Added support for "real kills"
  16. **
  17. ** Fixed in 1.4:
  18. ** o Version string is compliant to the C= guidelines
  19. **
  20. */
  21.  
  22. toconf  = 'The Keep'
  23. nomarkmsg = 0
  24.  
  25. options results
  26. options failat 30
  27.  
  28. signal on syntax
  29. signal on halt
  30. signal on break_c
  31.  
  32. CDF_NOT_ON_BBS   = '00008000'x  /* This conference is not on the bbs. */
  33.  
  34. /* Open Thor and BBSREAD ARexx ports' */
  35.  
  36. p=' '||address()||' '||show('P',,)
  37. if pos(' THOR.',p)>0 then thorport=word(substr(p,pos(' THOR.',p)+1),1)
  38. else do
  39.     say 'No THOR port found!'
  40.     exit(0)
  41.     end
  42.  
  43. if ~show('p', 'BBSREAD') then do
  44.     address command; "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
  45.     "WaitForPort BBSREAD"
  46.     if rc ~= 0 then do
  47.         address(thorport)
  48.         REQUESTNOTIFY '"Couldn''t open BBSRead''s ARexx port."' '"I see"'
  49.         exit(0)
  50.         end
  51.     end
  52.  
  53. address(thorport)
  54. trace off; CURRENTMSG curmsg; trace on
  55. if rc ~= 0 then do
  56.     REQUESTNOTIFY '"CURRENTMSG:\n'THOR.LASTERROR'"' '"Abort"'
  57.     exit(0)
  58.     end
  59.  
  60. GETMSGLISTSELECTED msgsel
  61. if rc = 3 | rc = 5 then do
  62.     msgsel.1 = curmsg.MSGNR; msgsel.COUNT = 1
  63.     end
  64. else if rc ~= 0 then do
  65.     REQUESTNOTIFY '"GETMSGLISTSELECTED:\n'THOR.LASTERROR'"' '"Abort"'
  66.     exit(0)
  67.     end
  68.  
  69. if msgsel.COUNT = 0 then do
  70.     msgsel.1 = curmsg.MSGNR; msgsel.COUNT = 1
  71.     end
  72.  
  73. address(bbsread)
  74. BUFMODE COPYBACK
  75.  
  76. do i = 1 to msgsel.COUNT
  77.     drop data. head. text.
  78.  
  79.     address(bbsread)
  80.     READBRMESSAGE '"'curmsg.BBSNAME'"' '"'curmsg.CONFNAME'"' '"'msgsel.i'"' TEXTSTEM text HEADSTEM head DATASTEM data
  81.     if rc ~= 0 then do
  82.         address(thorport)
  83.         REQUESTNOTIFY '"READBRMESSAGE (message #'msgsel.i'):\n 'BBSREAD.LASTERROR'"' '"Abort"'
  84.         signal cleanup
  85.         end
  86.  
  87.     if text.TEXT.COUNT = 0 & (text.PART.COUNT = 0 | symbol('text.PART.COUNT') ~= 'VAR') then do
  88.         address(thorport)
  89.         REQUESTNOTIFY '"No message body (message #'msgsel.i').\nMessage not copied."' '"'_Ok'"'
  90.         signal cleanup
  91.         end
  92.  
  93.     text.replyconf = curmsg.CONFNAME
  94.  
  95.     if head.fromname        ~= "HEAD.FROMNAME"        then text.fromname        = head.fromname
  96.     if head.fromaddr        ~= "HEAD.FROMADDR"        then text.fromaddr        = head.fromaddr
  97.     if head.toname          ~= "HEAD.TONAME"          then text.toname          = head.toname
  98.     if head.toaddr          ~= "HEAD.TOADDR"          then text.toaddr          = head.toaddr
  99.     if head.msgid           ~= "HEAD.MSGID"           then text.msgid           = head.msgid
  100.     if head.refid           ~= "HEAD.REFID"           then text.refid           = head.refid
  101.     if head.creationdate    ~= "HEAD.CREATIONDATE"    then text.creationdate    = head.creationdate
  102.     if head.creationdatetxt ~= "HEAD.CREATIONDATETXT" then text.creationdatetxt = head.creationdatetxt
  103.     if head.subject         ~= "HEAD.SUBJECT"         then text.subject         = head.subject
  104.  
  105.     red = ""; priv = ""; urg = ""; imp = ""; conf = ""
  106.     if bittst(data.flags, 0)  then red  = "READ"
  107.     if bittst(data.flags, 2)  then priv = "PRIVATE"
  108.     if bittst(data.flags, 11) then urg  = "URGENT"
  109.     if bittst(data.flags, 12) then imp  = "IMPORTANT"
  110.     if bittst(data.flags, 17) then conf = "CONFIDENTIAL"
  111.  
  112.     if nomarkmsg then nomark = 'DONTMARKMESSAGE'
  113.     else nomark = ''
  114.  
  115.     WRITEBRMESSAGE '"'curmsg.BBSNAME'"' '"'toconf'"' STEM text nomark red priv urg imp conf
  116.     if rc = 7 then do
  117.         CONFIGCONF '"'curmsg.BBSNAME'"' '"'toconf'"' SET c2x(CDF_NOT_ON_BBS)
  118.         WRITEBRMESSAGE '"'curmsg.BBSNAME'"' '"'toconf'"' STEM text nomark red priv urg imp conf
  119.         if rc ~= 0 then do
  120.             address(thorport)
  121.             REQUESTNOTIFY '"WRITEBRMESSAGE:\n'BBSREAD.LASTERROR'"' '"_Ok"'
  122.             signal cleanup
  123.             end
  124.         end
  125.     else if rc ~= 0 then do
  126.         address(thorport)
  127.         REQUESTNOTIFY '"WRITEBRMESSAGE:\n'BBSREAD.LASTERROR'"' '"_Ok"'
  128.         signal cleanup
  129.         end
  130.  
  131.     mnr = result
  132.     repl = ""
  133.     if bittst(data.flags, 1) then repl = "SETREPLIED"
  134.  
  135.     if mnr = -1 then do
  136.         REQUESTNOTIFY '"The message could not be written\nbecause it was caught by a kill entry."' '"_Ok"'
  137.         signal cleanup
  138.         end
  139.  
  140.     address(bbsread)
  141.     UPDATEBRMESSAGE '"'curmsg.BBSNAME'"' '"'toconf'"' mnr SETKEEP repl HAZELEVEL data.HAZELEVEL
  142.     if rc ~= 0 then do
  143.         address(thorport)
  144.         REQUESTNOTIFY '"UPDATEBRMESSAGE:\n'BBSREAD.LASTERROR'"' '"_Ok"'
  145.         signal cleanup
  146.         end
  147.     end
  148.  
  149. address(thorport)
  150. UPDATECONFWINDOW
  151.  
  152. signal cleanup
  153.  
  154. error:
  155. halt:
  156. break_c:
  157.  
  158. if rc ~= 0 then say '+++ Line 'sigl' returned 'rc': 'errortext(rc)
  159.  
  160. cleanup:
  161.  
  162. address(bbsread)
  163. BUFMODE ENDCOPYBACK
  164.  
  165. exit(0)
  166.